{"ast":null,"code":"import type from \"tinycolor2\";\nimport { Md5 } from 'ts-md5';\nconst getCorrectIndex = number => {\n  return number > 255 ? 255 : number < 0 ? 0 : number;\n};\nexport const generateAvatarByNickname = nickname => {\n  const hash = Md5.hashStr(nickname);\n  const [r, g, b] = hash.substring(0, 3).split(\"\").map(char => getCorrectIndex(char.charCodeAt(0)));\n  return {\n    colors: {\n      color: type({\n        r,\n        g,\n        b\n      }).lighten(10).saturate(10).toHexString(),\n      colorLighten: type({\n        r,\n        g,\n        b\n      }).lighten(30).saturate(30).toHexString()\n    }\n  };\n};\nexport default generateAvatarByNickname;","map":{"version":3,"names":["type","Md5","getCorrectIndex","number","generateAvatarByNickname","nickname","hash","hashStr","r","g","b","substring","split","map","char","charCodeAt","colors","color","lighten","saturate","toHexString","colorLighten"],"sources":["/data/messenger.client/src/utils/helpers/generateAvatarByNickname.ts"],"sourcesContent":["import type from \"tinycolor2\";\nimport {Md5} from 'ts-md5';\n\nconst getCorrectIndex = (number: number) => {\n    return (number > 255)? 255: (number < 0)? 0 : number;\n};\n\nexport const generateAvatarByNickname = (nickname: string) => {\n    const hash = Md5.hashStr(nickname);\n    const [r, g, b] = hash.substring(0, 3).split(\"\").map(char => getCorrectIndex(char.charCodeAt(0)));\n\n    return {\n        colors: {\n            color: type({ r, g, b })\n                .lighten(10)\n                .saturate(10)\n                .toHexString(),\n            colorLighten: type({ r, g, b })\n                .lighten(30)\n                .saturate(30)\n                .toHexString()\n        }\n    };\n};\n\nexport default generateAvatarByNickname;"],"mappings":"AAAA,OAAOA,IAAI,MAAM,YAAY;AAC7B,SAAQC,GAAG,QAAO,QAAQ;AAE1B,MAAMC,eAAe,GAAIC,MAAc,IAAK;EACxC,OAAQA,MAAM,GAAG,GAAG,GAAG,GAAG,GAAGA,MAAM,GAAG,CAAC,GAAG,CAAC,GAAGA,MAAM;AACxD,CAAC;AAED,OAAO,MAAMC,wBAAwB,GAAIC,QAAgB,IAAK;EAC1D,MAAMC,IAAI,GAAGL,GAAG,CAACM,OAAO,CAACF,QAAQ,CAAC;EAClC,MAAM,CAACG,CAAC,EAAEC,CAAC,EAAEC,CAAC,CAAC,GAAGJ,IAAI,CAACK,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAACC,KAAK,CAAC,EAAE,CAAC,CAACC,GAAG,CAACC,IAAI,IAAIZ,eAAe,CAACY,IAAI,CAACC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;EAEjG,OAAO;IACHC,MAAM,EAAE;MACJC,KAAK,EAAEjB,IAAI,CAAC;QAAEQ,CAAC;QAAEC,CAAC;QAAEC;MAAE,CAAC,CAAC,CACnBQ,OAAO,CAAC,EAAE,CAAC,CACXC,QAAQ,CAAC,EAAE,CAAC,CACZC,WAAW,EAAE;MAClBC,YAAY,EAAErB,IAAI,CAAC;QAAEQ,CAAC;QAAEC,CAAC;QAAEC;MAAE,CAAC,CAAC,CAC1BQ,OAAO,CAAC,EAAE,CAAC,CACXC,QAAQ,CAAC,EAAE,CAAC,CACZC,WAAW;IACpB;EACJ,CAAC;AACL,CAAC;AAED,eAAehB,wBAAwB"},"metadata":{},"sourceType":"module"}